<template>
	<view class="news-detail">
		
		<swiper indicator-dots autoplay :interval=1500 circular>
			<swiper-item v-for="item in swiperList" :key="item.id">
				<image :src="item.img">
				</iamge>
			</swiper-item>
		</swiper>
		
		
		<view class="title">
			{{newsDetailList.title}}
		</view>
		<view class="content" v-html="newsDetailList.content">
			{{newsDetailList.content}}
		</view>
		<view class="">
			发表时间: {{newsDetailList.add_time | formatDate }}
		</view>
		<view class="">
			浏览: {{newsDetailList.click}}
		</view>
		<!-- <view class="">
			文章id: {{newsDetailList.id}}
		</view> -->
		
	</view>
</template>

<script>
	export default {
		// 获取上个页面传递过来的参数
		onLoad(option) { //option为object类型，会序列化上个页面传递的参数
		    // console.log(option); //打印出上个页面传递的参数。
			this.getNewsDetail(option.id)
		},
		data() {
			return {
				newsDetailList: null
			}
		},
		methods: {
			// 
			async getNewsDetail(id) {
				const res = await this.$http({
					url:`/api/getnew/${id}`
				})
				this.newsDetailList = res.data.message[0]
				console.log(this.newsDetailList,222)
			}
		}
	}
</script>

<style lang="scss">
	.title {
		font-weight: 700;
		font-size: 50rpx;
		padding: 20rpx ;
		width: 750rpx;
	}
	.content {
		line-height: 70rpx;
	}
</style>
